package Ajax;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.http.HttpServletRequest;

public class ForjobsPage extends AbsPersonalPage {

	public ForjobsPage(String id, HttpServletRequest request) {
		super(id, request);
		mStrSubClassName = "resumeforjobs";
	}

	@Override
	public void execSql(Statement stmt, HttpServletRequest request)
			throws SQLException {
		if (bCreate) {
			return;
		}

		if (bSubmit) {
			String sql = "UPDATE resume SET "
					+ "jobskinds = " + Integer.valueOf(request.getParameter("jobskinds"))
					+ ", mulplace = '" + request.getParameter("mulplace")
					+ "', mulindustry = '" + request.getParameter("mulindustry")
					+ "', muljobstype = '" + request.getParameter("muljobstype")
					+ "', salaryid = " + Integer.valueOf(request.getParameter("salaryid"))
					+ ", salaryid1 = " + request.getParameter("salaryid1")
					+ ", salaryid2 = " + request.getParameter("salaryid2")
					+ " WHERE id = " + mResumeId;

			stmt.executeUpdate(sql);

			return;
		}

		if (bDelete) {
			return;
		}

		String sql = "SELECT resume.jobskinds, resume.mulplace, resume.mulindustry, resume.muljobstype, resume.salaryid," +
				 "cate_salaryid.list_name, cate_jobskinds.list_name FROM resume LEFT " +
			 	 "JOIN cate_salaryid ON resume.salaryid = cate_salaryid.id " +
				 "JOIN cate_jobskinds ON resume.jobskinds = cate_jobskinds.id WHERE resume.id = " + mResumeId;

		rs = stmt.executeQuery(sql);
	}

	@Override
	protected void writeWithoutCreate(PrintWriter writer) throws SQLException {
		if (rs == null || !rs.next()) {
			return;
		}

		writer.print("<form action=\"ResumeSys?action=personal&amp;option=resume&amp;extent=forjobs&amp;info=" + mResumeId + "&amp;submit=1\" name=\"wane_resume\" method=\"post\" target=\"ajaxform\" onsubmit=\"return resumeforjobs();\">");
		writer.println("<table cellpadding=\"0\" cellspacing=\"0\" class=\"formtable\" style=\"margin-bottom:30px;\"><caption><h2>求职意向</h2></caption><tr><th width=\"100\"><span class=\"warn\">*</span> 职位性质:</th>");
		writer.println("<td><a href=\"#\" onclick=\"category.load('tjobskinds','jobskinds',document.wane_resume.jobskinds.value);return false;\" class=\"select\"><span id=\"tjobskinds\">");
		writer.print(rs.getString("cate_jobskinds.list_name"));
		writer.print("</span></a><input type=\"hidden\" id=\"jobskinds\" name=\"jobskinds\" value=\"1\" />");
		writer.print("<input type=\"hidden\" id=\"djobskinds\" name=\"djobskinds\" value=\"");
		writer.print(rs.getString("cate_jobskinds.list_name"));
		writer.print("\"/></td></tr><tr><th>工作地点:</th>	<td><a href=\"#\" onclick=\"category.muload('mulplace','mulplace');return false;\" class=\"select\"><span id=\"mulplace\">");
		writer.print(rs.getString("resume.mulplace"));
		writer.print("</span></a><input type=\"hidden\" id=\"dmulplace\" name=\"mulplace\" value=\"\" /></td></tr><tr><th><span class=\"warn\">*</span> 所属行业:</th>	<td><a href=\"#\" onclick=\"category.muload('mulindustry','mulindustry');return false;\" class=\"select\"><span id=\"mulindustry\">");
		writer.print(rs.getString("resume.mulindustry"));
		writer.print("</span></a><input type=\"hidden\" id=\"dmulindustry\" name=\"mulindustry\" value=\"1\" /></td>	</tr><tr><th><span class=\"warn\">*</span> 职能职位:</th><td><a href=\"#\" onclick=\"category.muload('muljobstype','muljobstype');return false;\" class=\"select\"><span id=\"muljobstype\">");
		writer.print(rs.getString("resume.muljobstype"));
		writer.print("</span></a><input type=\"hidden\" id=\"dmuljobstype\" name=\"muljobstype\" value=\"1\" /></td></tr><tr><th><span class=\"warn\">*</span> 薪水标准:</th>	<td><a href=\"#\" onclick=\"category.load('tsalaryid','salaryid',document.wane_resume.salaryid.value);return false;\" class=\"select\"><span id=\"tsalaryid\">");
		writer.print(rs.getString("cate_salaryid.list_name"));
		writer.print("</span></a>  RMB<input type=\"hidden\" id=\"salaryid\" name=\"salaryid\" value=\"4\" /><input type=\"hidden\" id=\"dsalaryid\" name=\"dsalaryid\" value=\"1200-1500\" />");
		writer.println("</td></tr><tr><th>&nbsp;</th><td><input type=\"submit\" name=\"Submit\" value=\"保存修改\" class=\"submit\" />");
		writer.println("<input type=\"button\" name=\"nextstep\" value=\"跳到下一步\" onclick=\"resumeload('property')\" class=\"button\" /></td></tr></table></form>");
	}

	@Override
	protected void writeWithCreate(PrintWriter writer) throws IOException {
	}

}
